package com.example.securitydemo.exception;

import com.example.securitydemo.util.Constants;
import org.springframework.context.MessageSource;
import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;

import javax.annotation.Nullable;
import java.net.URI;
import java.util.Locale;

/**
 * Created by Guaguaerhao on 2021/4/21 23:40
 */
public class DuplicateProblem extends AbstractThrowableProblem {
    private static final URI TYPE = URI.create(Constants.PROBLEM_BASE_URI + "/duplicate");
    public DuplicateProblem(String message) {
        super(TYPE, "发现重复数据", Status.CONFLICT, message);
    }
    public DuplicateProblem(String msgCode, MessageSource messageSource, Locale locale) {
        super(
                TYPE,
                messageSource.getMessage("Exception.duplicate.title", null, locale),
                Status.CONFLICT,
                messageSource.getMessage(msgCode, null, locale));
    }
}
